<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<!-- STYLESHEETS -->
	<!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
	<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
	<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
	<link rel="stylesheet" type="text/css" href="../../css/responsive.css">

	<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<!-- file-input -->
	<link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
	<!-- SELECT2 -->
	<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
	<!-- UNIFORM -->
	<link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
	<!-- datatable -->
	<link rel="stylesheet" href="../../js/datatables/datatable.css">
	<!-- WIZARD -->
	<link rel="stylesheet" type="text/css" href="../../js/bootstrap-wizard/wizard.css" />
	<link rel="stylesheet" href="../../js/datepicker/datepicker.css">
	<!-- FONTS
<link href='http://fonts.useso.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
-->
	<!-- JQUERY -->
	<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
	<script src="../../js/common.js"></script>
</head>

<body>
<header class="navbar clearfix" id="header">
</header>

<!-- PAGE -->
<section id="page">
	<!-- SIDEBAR -->
	<div id="sidebar" class="sidebar">
		<div class="sidebar-menu nav-collapse">

			<!-- SIDEBAR MENU -->
			<ul>

			</ul>
			<!-- /SIDEBAR MENU -->
		</div>

	</div>
	<!-- /SIDEBAR -->
	<div id="main-content">
		<div class="modal fade" id="update_stock_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">修改库存</h4>
							</div>
							<div class="modal-body">
								<div class="form-group" style="margin-bottom:0px">
									<label class="control-label col-md-3" >skuCode：</label>
									<div class="col-md-4 skuCode">		
										<input name = 'pid' hidden="true">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3" style="line-height:34px;">数量：</label>
									<div class="col-md-6">
											<input type="text" class="form-control" name="amount" maxlength="20" />
									</div>
								</div>
							</div>
							
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
								<button type="button" class="btn btn-success bt-save">保存</button>
							</div>
						</div>
					</div>
				</div>
		<div class="container">
			<div class="row">
				<div id="content" class="col-lg-12">
					<!-- PAGE HEADER-->
					<div class="row">
						<div class="col-sm-12">
							<div class="page-header">
								<!-- STYLER -->

								<!-- /STYLER -->
								<!-- BREADCRUMBS -->
								<ul class="breadcrumb">
									<li>
										<i class="fa fa-home"></i>
										<a href="index.html">首页</a>
									</li>
									<li>
										<a href="#">合同管理</a>
									</li>
									<li>进货管理</li>
								</ul>
								<!-- /BREADCRUMBS -->

							</div>
						</div>
					</div>
					<!-- /PAGE HEADER -->
					<!-- SAMPLE -->
					<form id="form_detail">
						<div class="box" style="margin-top:10px">
							<div class="box-title" style="border-bottom:1px solid #5e87b0;line-height:38px">
								<h4><i class="fa fa-file" style="color:red"></i>基本信息</h4>
							</div>
							<div class="box-body">
								<div class="form-group  mrg-bt10">
									<label class="control-label col-md-2 " style="width:100px">展会名称：</label>
									<div class="col-md-3 inline" name="actionName"></div>
									<label class="col-sm-1 control-label" style="width: auto">展会日期：</label>
									<div class="col-sm-4" style="display:inline-flex" name ="actionDate">
									</div>
									
								</div>
							</div>
							<div class="box-body">
								<div class="form-group  mrg-bt10">
									<label class="control-label col-md-2 " style="width:100px">创建人：</label>
									<div class="col-md-3 inline" name="createBy"></div>
									<label class="col-sm-1 control-label" style="width: auto">创建时间：</label>
									<div class="col-md-3 inline" name="createTime"></div>
							</div>
						</div>
						<div class="box" style="margin-top:10px">
						<div class="box-title" style="border-bottom:1px solid #5e87b0;line-height:38px">
											<h4><i class="fa fa-file" style="color:red"></i>商品明细</h4>
						</div>
						<div class="box-body">
							<div class="form-group  mrg-bt10">
								<table id="db_list" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
												
								</table>
								
							</div>
							
						</div>
						
						</div>

					</form>
					<!-- /SAMPLE -->

					<div class="footer-tools">
								<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
					</div>
				</div>
				<!-- /CONTENT-->
			</div>
		</div>
	</div>
</section>
<!--/PAGE -->
<!-- JAVASCRIPTS -->
<!-- Placed at the end of the document so the pages load faster -->

<!-- BOOTSTRAP -->
<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>

<!-- BLOCK UI -->
<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
<!--bootbox-->
<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
<!-- AUTOSIZE -->
<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
<!-- spinner -->
<script src="../../js/spinner/spin.js"></script>
<!-- DATA TABLES -->
<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
<script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>
<!-- INPUT MASK -->
<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>

<!-- SELECT2 -->
<script type="text/javascript" src="../../js/select2/select2.min.js"></script>

<!-- UNIFORM -->
<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
<script type="text/javascript" src="../../js/datepicker/datepicker.js"></script>
<script src="../../js/jquery-validate/jquery.validate.min.js"></script>
<!-- COOKIE -->
<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
<!-- CUSTOM SCRIPT -->
<script src="../../js/script.js"></script>

<script src="../../js/Sortable.min.js"></script>
<script>
	var actionId = $.getUrlParam("id");
	var detailpage = function() {
		var searchProduct=function(){
			  var $mainDataTable=null; 
			  var url=App.getContextPath()+"admin/action/searchProduct.do?actionId="+actionId;
			  if($mainDataTable){
				   $mainDataTable.api().ajax.url(url).load();	   		
				   return;	
			   }
			   var dtSetting = $.dataTableSetting({			
				   "ajaxSource" :url,
						"serverSide" : true,
						"bFilter" : false,// 去掉搜索框
						"bLengthChange" : true,// 每页显示数量							
						"sScrollX":"100%",
						"sScrollXInner": "100%",
						"iDisplayLength": 25,
						
						"bSort" : false,					
						"aoColumns" : [ {
							"mDataProp" : "productName",
							"sTitle" : "商品名称",
							"width" : "10%"			
						}, {
							"mDataProp" : "productCode",
							"sTitle" : "商品编码",
							"width" : "10%",
						}, {
							"mDataProp" : "shortName",
							"sTitle" : "颜色",
							"width" : "7%"
						}, {
							"mDataProp" : "size",
							"sTitle" : "规格/大小",
							"width" : "7%"
						}, {
							"sTitle" : "单价",
							"width" : "8%",
							"render":function(data, type, row){
							   return row.salesPrice.toFixed(4);
							}
						}, {
							"sTitle" : "录入数量",
							"width" : "8%",
							"render":function(data, type, row){
								return format_number(row.amount);
							}
						}, {
							"sTitle" : "操作",
							"width" : "8%",
							"render":function(data, type, row){
								 var str="<a  class='btn btn-warning btn-update-stock btn-width' pid='"+row.id+"' skuCode='"+row.skuCode+"'  style='width:100px;margin-left:0px;margin-right:5px;margin-top:2px;'><i class='fa fa-arrow-circle-o-up'></i>更新库存</a>";
								return str;
							}
						}]
					});
				
				  $mainDataTable = $("#db_list").dataTable(dtSetting);
			 };
			 var updateStock = function(){
				// btn-update-stock
				var skuCode = $(this).attr("skuCode");
				var pid = $(this).attr("pid");
				$("#update_stock_config").find(".skuCode").html(skuCode);
				$("#update_stock_config").modal('show');
				 $("#update_stock_config").find('.bt-save').click(function(){
					var amount =  $("#update_stock_config").find('input[name=amount]').val();
					if(!amount)
						$.alert("请输入库存")
					 $.ajax({
							type: "post",
							url: App.getContextPath()+"admin/action/updateStock.do",
							async: true,
							data: {pid:pid,amount:amount},
							success: function(result) {
								
								console.log(result);
								$("#update_stock_config").modal('hide');
								searchProduct();
							}
						}); 
				 });		
			 }
			 
		return {
			init: function() {
				App.init();
				  $("#db_list").on("click",".btn-update-stock",updateStock);
				$.ajax({
					type: "post",
					url: App.getContextPath()+"admin/action/getActionById.do",
					async: true,
					data: {actionId:actionId},
					success: function(result) {
						
						console.log(result);
						
						if(result.type=='success'){
							$("div[name=actionName]").html(result.extra.actionName);
							$("div[name=actionDate]").html($.getLocalDate(result.extra.startDate)+"  至  "+$.getLocalDate(result.extra.endDate) );
							$("div[name=createBy]").html(result.extra.createBy);
							$("div[name=createTime]").html($.getLocalDate(result.extra.createTime));
							searchProduct();
						}
					}
				});
			}
		}
	}();
	
	 
	$(function() {
		$("#header").load("../head.html");
		detailpage.init();
		$(".go-top").hide();
	});
			 
	
</script>

<!-- /JAVASCRIPTS -->
</body>

</html>